﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace PoundConsole.common
{
    public class BaseClient
    {
        public static async Task Post(string url,string json)
        {
            using (var httpClient = new HttpClient())
            {

                var content = new StringContent(json, Encoding.UTF8, "application/json");

                try
                {
                    // 发送POST请求
                    var response = await httpClient.PostAsync(
                        url,
                        content
                    );

                    response.EnsureSuccessStatusCode();
                    string result = await response.Content.ReadAsStringAsync();
                    Console.WriteLine("响应内容: " + result);
                }
                catch (HttpRequestException ex)
                {
                    Console.WriteLine("请求错误: " + ex.Message);
                }
            }
        }
    }
}
